public class Tax {
    private int status; //纳税人状态
    private static final int SINGLE = 0; //单身纳税人
    private static final int MARRIED = 1; //已婚共缴纳税人
    private static final int HOUSEHOLD = 2; //家庭纳税人
    private int[][] brackets; //每种纳税人的纳税等级
    private double[] rates; //每种纳税等级的税率
    private int income; //收入

    private void setDefaultBrackets() {
        brackets = new int[3][];
        for (int i = 0; i <= 2; i++) brackets[i] = new int[5];
        brackets[0][0] = 0;
        brackets[0][1] = 27050;
        brackets[0][2] = 65550;
        brackets[0][3] = 136750;
        brackets[0][4] = 297350;
        brackets[1][0] = 0;
        brackets[1][1] = 45200;
        brackets[1][2] = 109250;
        brackets[1][3] = 166500;
        brackets[1][4] = 297350;
        brackets[2][0] = 0;
        brackets[2][1] = 36250;
        brackets[2][2] = 93650;
        brackets[2][3] = 151650;
        brackets[2][4] = 297350;
    }

    private void setDefaultRates() {
        rates = new double[5];
        rates[0] = 0.15;
        rates[1] = 0.275;
        rates[2] = 0.305;
        rates[3] = 0.355;
        rates[4] = 0.391;
    }

    public Tax(int status, int income) {
        this.status = status;
        this.income = income;
        setDefaultBrackets();
        setDefaultRates();
    }

    public Tax(int status, int[][] brackets, double[] rates, int income) {
        this.status = status;
        this.income = income;
        this.brackets = brackets;
        this.rates = rates;
    }

    public int getStatus() {
        return status;
    }

    public int[][] getBrackets() {
        return brackets;
    }

    public double[] getRates() {
        return rates;
    }

    public int getIncome() {
        return income;
    }

    public double getTax() {
        double ret = 0;
        for (int i = 1; i <= 4; i++) {
            if (income <= brackets[status][i]) {
                ret += (income - brackets[status][i - 1]) * rates[i - 1];
                ret = Math.round(ret * 100) * 1.0 / 100;
                return ret;
            }
            else ret += (brackets[status][i] - brackets[status][i - 1]) * rates[i - 1];
        }
        ret += (income - brackets[status][4]) * rates[4];
        ret = Math.round(ret * 100) * 1.0 / 100;
        return ret;
    }

    public void setIncome(int income) {
        this.income = income;
    }

    public void printTax() {
        if (status == 0) System.out.println("纳税人类型：单身纳税人 收入：" + income + " 税款：" + getTax());
        else if (status == 1) System.out.println("纳税人类型：已婚共缴纳税人 收入：" + income + " 税款：" + getTax());
        else if (status == 2) System.out.println("纳税人类型：家庭纳税人 收入：" + income + " 税款：" + getTax());
    }

    public static void main(String atrs[]) {
        Tax t0 = new Tax(0, 50000);
        Tax t1 = new Tax(1, 50000);
        Tax t2 = new Tax(2, 50000);
        t0.printTax();
        t1.printTax();
        t2.printTax();
        for (int income = 51000; income <= 60000; income += 1000) {
            t0.setIncome(income);
            t0.printTax();
            t1.setIncome(income);
            t1.printTax();
            t2.setIncome(income);
            t2.printTax();
        }
    }
}
